package hu.sulirend.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 * Unites StudentGroups which contains all members of the Clazz in a disjunct manner.
 * 
 * @see <code>hu.sulirend.model.Clazz</code>
 * @see <code>hu.sulirend.model.StudentGroup</code>
 *
 * @author <a href="mailto: peter.szilagyi@gmail.com">Peter Szilagyi</a> 
 * @since 2008
 */
@Entity
public class ClazzGroups extends BaseEntity {

	private static final long serialVersionUID = 886010559570330782L;
	
	private Clazz clazz;
	private Set<StudentGroup> studentGroups;
	
	@ManyToOne(optional=false, fetch=FetchType.LAZY, cascade={CascadeType.ALL})
	@JoinColumn(name="CLAZZ_ID", referencedColumnName="id", unique=false, nullable=false, updatable=true, insertable=true)
	public Clazz getClazz() {
		return clazz;
	}
	public void setClazz(Clazz clazz) {
		this.clazz = clazz;
	}
	@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL}, mappedBy="clazzGroups")
	public Set<StudentGroup> getStudentGroups() {
		return studentGroups;
	}
	public void setStudentGroups(Set<StudentGroup> studentGroups) {
		this.studentGroups = studentGroups;
	}
	
}
